-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Makefile and CI to run make build #11
Conversation
996b147
to
6d5a608
Compare
.gitignore
Outdated
@@ -0,0 +1,11 @@ | |||
# binary files | |||
protoc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are installed inside the folder name called google right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, they are directly inside our repo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ew, better not do that
Makefile
Outdated
install-deps: | ||
ifndef PROTOC | ||
# download protoc | ||
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/protoc-3.14.0-linux-x86_64.zip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/protoc-3.14.0-linux-x86_64.zip | |
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/${PROTOC_VERSION}/protoc-3.14.0-linux-x86_64.zip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for all the tools we installed the version should be defined as a variable above and we should use the same here.
Makefile
Outdated
|
||
build: install-deps | ||
# generate libs | ||
./protoc --go_out=lib/go/replication --go_opt=paths=source_relative --plugin=./protoc-gen-go *.proto |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
./protoc --go_out=lib/go/replication --go_opt=paths=source_relative --plugin=./protoc-gen-go *.proto | |
./protoc --go_out=lib/go/replication --go_opt=paths=source_relative --plugin=./protoc-gen-go replication.proto |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the file name but can not change the indentation. It gives an error
Makefile
Outdated
rm -rf protoc \ | ||
protoc-gen-go \ | ||
protoc-gen-go-grpc \ | ||
protoc-3.14.0-linux-x86_64.zip \ | ||
protoc-gen-go.v1.25.0.linux.386.tar.gz \ | ||
protoc-gen-go-grpc.v1.1.0.linux.386.tar.gz \ | ||
google/protobuf/*.proto |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation? and also its good to install these packages to a folder and remove the folder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just some nits to consider for improvement
Makefile
Outdated
install-deps: | ||
ifndef PROTOC | ||
# download protoc | ||
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/protoc-3.14.0-linux-x86_64.zip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better download in a sub-directory and not clutter the root of the project with unneeded files.
Same counts for the extraction, run it from a different directory.
Makefile
Outdated
endif | ||
|
||
clean: | ||
rm -rf protoc \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why pass -r
for recursive? I do not think any directories are removed here?
It probably is not a good idea to remove the downloaded dependencies with make clean
. A next make
will need to download them again, that does not seem very useful. make clean
should remove compiled/generated files, I recommend to introduce a different target for cleaning up everything, maybe make dep-clean
or something like it.
Makefile
Outdated
PROTOC_GEN_GO_REQ := "protoc-gen-go v1.25.0" | ||
PROTOC_GEN_GO_GRPC_REQ := "protoc-gen-go-grpc 1.1.0" | ||
|
||
PROTOC := $(shell ([ "`$(PWD)/protoc --version 2> /dev/null`" == $(PROTOC_REQ) ] && echo true)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
passing && echo true
is a little strange to read, you could rewrite it to something easier to understand like:
PROTOC_VERSION := $(shell ./protoc --version 2>/dev/null)
ifeq($(PROTOC_VERSION),$(PROTOC_REQ)
HAVE_PROTOC := "yes"
endif
After that, you can use ifdef HAVE_PROTOC
to check if it is available. This reads more similar to how other projects use detection of features/settings/...
Makefile
Outdated
protoc-gen-go \ | ||
protoc-gen-go-grpc \ | ||
protoc-3.14.0-linux-x86_64.zip \ | ||
protoc-gen-go.v1.25.0.linux.386.tar.gz \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really, it would be so much cleaner to place downloaded files in ./dist/
and executables in ./bin/
.gitignore
Outdated
@@ -0,0 +1,11 @@ | |||
# binary files | |||
protoc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ew, better not do that
@@ -1,20 +1,16 @@ | |||
// Code generated by protoc-gen-go. DO NOT EDIT. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explain in the commit how these files are generated. You added a make target, so the command in the commit should be make ...
.
@nixpanic Can you pls take a look again at fresh as the whole structure is changed now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks much cleaner to me, way easier to understand what is done and where non-repository files are located.
Thanks!
Makefile
Outdated
PROTOC_GEN_GO_GRPC_FOUND := $(shell ./bin/protoc-gen-go-grpc --version 2> /dev/null) | ||
|
||
|
||
ifeq ("$(PROTOC_FOUND)","libprotoc ${PROTOC_VERSION}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you tested this? there is a mix of $(...)
(make) and ${...}
(bash) notation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I did both are working similarly for me. Anyway, I have changed it to curly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. one minor comment to check *.go files after make build
in CI
|
||
- name: generate go libs using protoc | ||
run: | | ||
make build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we check that pushed*.go files are not having any changes once we do make the build here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Signed-off-by: Nitin Goyal <[email protected]>
Signed-off-by: Nitin Goyal <[email protected]>
Signed-off-by: Nitin Goyal <[email protected]>
Signed-off-by: Nitin Goyal <[email protected]>
Signed-off-by: Nitin Goyal [email protected]